package licode.unisop.platform.client.feign.impl;

import licode.unisop.platform.client.api.SiPlatformAuthService;
import licode.unisop.platform.client.feign.PlatformAuthApiFeign;
import licode.unisop.platform.client.info.PlatformAuthInfo;
import licode.unisop.platform.client.info.PlatformHeartInfo;
import licode.unisop.platform.client.vo.PlatAuthVO;
import licode.unisop.provider.info.SiLookupAssetIn;
import licode.unisop.provider.info.SiPlatIdFind;
import licode.unisop.provider.info.SiPlatformId;
import licode.unisop.provider.vo.SiAsset;
import licode.unisop.provider.vo.SiAssetInfo;
import licode.unisop.provider.vo.SiPlatform;
import licode.unisop.unilite.utils.TryMethodCall;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 平台认证查询远程实现
 *
 * @author licode
 */
@Component
public class SiPlatformAuthServiceFeignImpl implements SiPlatformAuthService {
    @Resource
    private PlatformAuthApiFeign platformAuthApiFeign;


    @Override
    public void updateCache(SiPlatformId platId) {
        TryMethodCall.execFeign(() -> platformAuthApiFeign.updateCache(platId));
    }

    @Override
    public PlatAuthVO register(PlatformAuthInfo info) {
        return TryMethodCall.execFeign(() -> platformAuthApiFeign.register(info));
    }

    @Override
    public PlatAuthVO fromId(SiPlatIdFind idInfo) {
        return TryMethodCall.execFeign(() -> platformAuthApiFeign.fromId(idInfo));
    }

    @Override
    public SiPlatform getAuthPlatform(SiPlatIdFind idInfo) {
        return null;
    }

    @Override
    public SiPlatform getPlatformAndCheck(SiPlatIdFind idInfo) {
        return null;
    }

    @Override
    public SiAssetInfo getPlatformAssets(SiPlatIdFind idInfo) {
        return null;
    }

    @Override
    public List<SiAsset> lookPlatformAsset(SiLookupAssetIn lookupIn) {
        return null;
    }

    @Override
    public long getAuthCount() {
        return TryMethodCall.execFeign(() -> platformAuthApiFeign.getAuthCount());
    }

    @Override
    public void forbid(SiPlatformId idInfo) {
        TryMethodCall.execFeign(() -> platformAuthApiFeign.forbid(idInfo));
    }

    @Override
    public String renew(PlatformHeartInfo info) {
        return TryMethodCall.execFeign(() -> platformAuthApiFeign.renew(info));
    }
}
